home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-07-03 | 3.3 KB | 231 lines | [TEXT/KAHL] |
-
- /****
- * GetEText()
- *
- * Get text of an ETItem
- *
- ****/
-
- GetEText (theDialog, theItem, s)
- DialogPtr theDialog;
- int theItem;
- char *s;
- {
- int theType;
- Handle Hdl;
- Rect box;
-
- GetDItem (theDialog, theItem, &theType, &Hdl, &box);
- GetIText (Hdl, s);
- }
- /* end GetEText */
-
-
- /****
- * GetETNum()
- *
- * Get number from an ETItem
- *
- ****/
-
- GetETNum(theDialog, theItem)
- DialogPtr theDialog;
- int theItem;
- {
- Str255 s;
- long theNum;
-
- GetEText(theDialog, theItem, &s);
- StringToNum(s, &theNum);
- return(theNum);
- }
- /* end GetETNum */
-
-
- /****
- * SetEText()
- *
- * Set text of an ETItem
- *
- ****/
-
- SetEText (theDialog, theItem, s)
- DialogPtr theDialog;
- int theItem;
- Str255 s;
- {
- int theType;
- Handle Hdl;
- Rect box;
-
- GetDItem (theDialog, theItem, &theType, &Hdl, &box);
- SetIText (Hdl, s);
- }
- /* end SetEText */
-
-
- /****
- * SetETNum()
- *
- * Set number in an ETItem
- *
- ****/
-
- SetETNum(theDialog, theItem, theNum)
- DialogPtr theDialog;
- int theItem;
- long theNum;
- {
- Str255 s;
-
- NumToString(theNum, s);
- SetEText(theDialog, theItem, &s);
- }
- /* end GetETNum */
-
-
- /*****
- * LToGRect()
- *
- * Convert a local rect to global
- *
- *****/
-
- LToGRect(r)
- Rect *r;
- {
- Point pt1,
- pt2;
-
- pt1 = topLeft(*r);
- pt2 = botRight(*r);
- LocalToGlobal(&pt1);
- LocalToGlobal(&pt2);
- Pt2Rect(pt1, pt2, r);
- }
- /* end LToGRect */
-
-
- /*****
- * CenterWindowPoint()
- *
- * Calculates the topleft co-ords of a window,
- * taking screen size into account
- *
- *****/
-
- Point
- CenterWindowPoint (theRect)
- Rect *theRect;
-
- {
- int theInd = (screenBits.bounds.bottom<350) ? 3:4;
- Point thePt;
- int int1,
- int2;
-
- int1=((screenBits.bounds.right-screenBits.bounds.left-theRect->right+theRect->left) / 2);
- int2=((screenBits.bounds.bottom-screenBits.bounds.top-theRect->bottom+theRect->top+20) / theInd);
- SetPt(&thePt, int1, int2);
- return(thePt);
- }
- /* end CenterWindowPoint */
-
-
- /*****
- * CenterWindow()
- *
- * Centers a dialog or window
- *
- *****/
-
- void
- CenterWindow(theDialog)
- DialogPtr theDialog;
- /* Center window - center slightly higher for large screens */
- {
- Point thePt;
- Rect newBounds;
-
- newBounds = *&theDialog->portRect;
- LToGRect(&newBounds);
- thePt = CenterWindowPoint(&newBounds);
- MoveWindow(theDialog, thePt.h, thePt.v, 0);
- }
- /* end CenterWindow */
-
-
- /****
- * ClickButton()
- *
- * Simulate a click in a button
- *
- ****/
-
- ClickButton(theDialog, ID, method) /* 0 is off, 1 is on, 2 simulates a click */
- DialogPtr theDialog;
- int ID;
- int method;
- {
- int itemType;
- Handle item;
- Rect box;
- long ticks;
-
- GetDItem(theDialog, ID, &itemType, &item, &box);
- HiliteControl((ControlHandle) item, (method >= 1));
- if (method >= 2)
- {
- Delay(8L, &ticks);
- HiliteControl((ControlHandle) item, 0);
- }
- }
- /* end ClickButton */
-
-
- /****
- * FrameItem()
- *
- * Frame a dialog item in current pen modes
- *
- ****/
-
- void
- FrameItem (theDialog, item)
- DialogPtr theDialog;
- int item;
- {
- int optType;
- Handle btnHdl;
- Rect optBox;
-
- SetPort(theDialog);
- GetDItem(theDialog, item, &optType, &btnHdl, &optBox);
- FrameRect(&optBox);
- }
- /* end FrameItem */
-
-
- /****
- * DrawDefaultBtn()
- *
- * Outline the default button
- *
- ****/
-
- void
- DrawDefaultBtn (theDialog, item)
- DialogPtr theDialog;
- int item;
- {
- int optType;
- Handle btnHdl;
- Rect optBox;
-
- SetPort(theDialog);
- GetDItem(theDialog, item, &optType, &btnHdl, &optBox);
- PenSize(3, 3);
- InsetRect(&optBox, -4, -4);
- FrameRoundRect(&optBox, 16, 16);
- }
- /* end DrawDefaultBtn */